<?php
/**
 * @author all@cosmos-framework.org
 * @copyright (c) 2013 cosmos-framework.org
 * @license http://www.opensource.org/licenses/mit-license.php
 * @link http://cosmos-framework.org/
 * @package cosmos.framework
 * @version 2.0
 */
namespace Cosmos;

class Logger {

    /**
     * @param string $message
     */
    public static function alert($message) {

        self::_log(LOG_ALERT, $message);
    }

    /**
     * @param string $message
     */
    public static function crit($message) {

        self::_log(LOG_CRIT, $message);
    }

    /**
     * @param string $message
     */
    public static function debug($message) {

        self::_log(LOG_DEBUG, $message);
    }

    /**
     * @param string $message
     */
    public static function emerg($message) {

        self::_log(LOG_EMERG, $message);
    }

    /**
     * @param string $message
     */
    public static function err($message) {

        self::_log(LOG_ERR, $message);
    }

    /**
     * @param string $message
     */
    public static function info($message) {

        self::_log(LOG_INFO, $message);
    }

    /**
     * @param string $message
     */
    public static function notice($message) {

        self::_log(LOG_NOTICE, $message);
    }

    /**
     * @param string $message
     */
    public static function warning($message) {

        self::_log(LOG_WARNING, $message);
    }

    /**
     * @param int $priority
     * @param string $message
     */
    private static function _log($priority, $message) {

        global $_FACILITY;

        // Apr  1 00:00:00 host [pid]: { message }

        openlog('', LOG_CONS | LOG_ODELAY | LOG_PID, $_FACILITY ? : LOG_USER);

        syslog($priority, $message);

        closelog();
    }

}
